package com.jhws.sys.cms.controller;

import com.jhws.common.base.bo.JsonRespData;
import com.jhws.sys.cms.bo.ResourceCustomType;
import com.jhws.sys.cms.service.ResourceTypeService;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
@RequestMapping("/cms/resource/type")
public class ResourceTypeController {

    @Resource
    private ResourceTypeService resourceTypeService;

    @RequestMapping("queryResourceTypes.x")
    @RequiresRoles("admin")
    @ResponseBody
    public JsonRespData queryResourceTypes() {
        return new JsonRespData("", 1, resourceTypeService.queryTypesByWhere(""));
    }

    @RequestMapping("saveCustomType.x")
    @RequiresRoles("admin")
    @ResponseBody
    public JsonRespData saveCustomType(ResourceCustomType customType) {
        String customTypeId = resourceTypeService.saveResourceCustomType(customType);
        return new JsonRespData("", 1, customTypeId);
    }
}
